﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

namespace PPM.Blog.Domain.Core
{
    [Table("T_Menu", Schema = "dbo")]
    public class Menu
    {
        public Menu()
        {
            this.Name = string.Empty;
            this.Status = StatusEnum.Normal;
            this.Level = LevelEnum.First;
            this.ParentId = null;
            this.Children = new HashSet<Menu>();
        }
        [Key]
        public int Id { get; set; }

        public int? ParentId { get; set; }
        [Required]
        [StringLength(10)]
        public string Name { get; set; }

        [Required]
        [StringLength(20)]
        public string Url { get; set; }


        [StringLength(20)]
        public string Icon { get; set; }


        [StringLength(1000)]
        public string Description { get; set; }


        public LevelEnum Level { get; set; }
        public StatusEnum Status { get; set; }



        public int CreatorId { get; set; }

        public DateTime CreateTime { get; set; }

        
        public int? LastModifierId { get; set; }

        public DateTime? LastModifyTime { get; set; }

        [ForeignKey("CreatorId")]
        public virtual User Creator { get; set; }

        [ForeignKey("LastModifierId")]
        public virtual User LastModifier { get; set; }



        [ForeignKey("ParentId")]
        public virtual Menu Parent { get; set; }



        [InverseProperty("Parent")]
        public virtual ICollection<Menu> Children { get; set; }
    }
}